﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Data.SqlClient;

namespace W5_DoAnCuoiKy_Glow
{
    public class FunctionAndSub
    {
        public static void KhoaTaiKhoan(string _maTK, int songay)
        {
            //@MaTK int
            //@songay int

            string sql = "sp_KhoaTaiKhoan";
            List<SqlParameter> listPara = new List<SqlParameter>();

            SqlParameter MaTK = new SqlParameter("@MaTK", SqlDbType.VarChar);
            MaTK.Value = _maTK;
            listPara.Add(MaTK);

            SqlParameter SoNgay = new SqlParameter("@songay", SqlDbType.Int);
            SoNgay.Value = songay;
            listPara.Add(SoNgay);

            DataProvider.ExcuteQueryProc(sql, listPara);
        }

        public static string MD5(string password)
        {
            byte[] textBytes = System.Text.Encoding.Default.GetBytes(password);
            try
            {
                System.Security.Cryptography.MD5CryptoServiceProvider cryptHandler;
                cryptHandler = new System.Security.Cryptography.MD5CryptoServiceProvider();
                byte[] hash = cryptHandler.ComputeHash(textBytes);
                string ret = "";
                foreach (byte a in hash)
                {
                    if (a < 16)
                        ret += "0" + a.ToString("x");
                    else
                        ret += a.ToString("x");
                }
                return ret;
            }
            catch
            {
                throw;
            }
        }

    }
}
